import vue from '@vitejs/plugin-vue'
import ViteCompression from 'vite-plugin-compression'
const timestamp = new Date().getTime()
export default {
    base: '/zhwl_admin/',
    build: {
        chunkSizeWarningLimit: 1000,
        outDir: "zhwl_admin",
        assetsDir: "assets", //指定静态资源存放路径
        // assetsPublicPath:'',
        sourcemap: true, //是否构建source map 文件
        rollupOptions: {
            output: {
                entryFileNames: `assets/[name].${timestamp}.js`,
                chunkFileNames: `assets/[name].${timestamp}.js`,
                assetFileNames: `assets/[name].${timestamp}.[ext]`,
                // entryFileNames: `assets/[name].js`,
                // chunkFileNames: `assets/[name].js`,
                // assetFileNames: `assets/[name].[ext]`,
            }
        },
        terserOptions: {
            // 生产环境移除console
            compress: {
                drop_console: true,
                drop_debugger: true,
            }
        }
    },
    plugins: [
        vue(),ViteCompression()
    ],
    optimizeDeps: {
        include: ['schart.js']
    },
    //配置跨域
    server: {
        open: false,  //启动项目后打开浏览器
        port: 3000,   //端口
        proxy: {
            '/manage': {
                target: 'http://192.168.1.196:8003',  //API服务地址
                changeOrigin: true,             //开启跨域
                // rewrite: (path) => path.replace(/^\/manage/, '') // 将api替换为空
            },
            '/upload': {
                target: 'http://192.168.1.196:8003',  //API服务地址
                changeOrigin: true,             //开启跨域
                // rewrite: (path) => path.replace(/^\/upload/, '') // 将api替换为空
            }
        }
    }
}
